<?php
/**
 * Класс Controller_Index отвечает за главную страницу
 * @author Mike
 */
class Controller_Index extends Controller_Base {
	
	public function action() {
		$this->getIndexPage();
	}

	/**
	 * Главная страница
	 */
	private function getIndexPage() {
		$objProduct = new Product();
		/*$arrPopularProducts = $objProduct->find('all', array(
            'select' => '
                `product`.`url`,
                `product`.`product_name`,
                `product`.`client_price`,
                `product`.`reviews_score`,
                `product`.`ID_photo`, 5 * `product`.`wordstat_buy` + 2 * `product`.`wordstat_price` + `product`.`wordstat_simple` `ranking`',
            'order' => '`ranking` DESC',
            'limit' => 12
		));*/
		
		$arrPopularProducts = $objProduct->find('all', array(
				'select' => '`product`.`url`, `product`.`product_name`, `product`.`client_price`, `product`.`reviews_score`, `product`.`ID_photo`',
				'joins' => 'INNER JOIN `product_selection` USING(`ID_product`) INNER JOIN `selection` USING(`ID_selection`)',
				'conditions' => '`selection`.`is_main` = 1',
				'order' => '`ID_category` DESC',
				'limit' => 12
		));
		
		$objArticle = new Article(1);
		
		$this->description = $objArticle->getField('description');
		$this->title = $objArticle->getField('title');
		$this->keywords = $objArticle->getField('keywords');
		$this->bodyAttr = 'index';
	
		$this->showHeader();
			View_Index::showIndexPage($arrPopularProducts);
		$this->showFooter();
	}
	

	/**
	 * Левый столбец
	 */
	/**
	protected function showLeft() {
		echo '<div id="left">';
			echo '<div class="cat-list sh-block">';
				echo '<div class="head-line">Для мужчин</div>';
				echo '<a href="' . W_ABSPATH . 'categories/clothes" class="branch stage1">Одежда</a>';
				echo '<a href="' . W_ABSPATH . 'categories/shoes" class="branch stage1">Обувь</a>';
				
				echo '<div class="head-line">Для женщин</div>';
				echo '<a href="' . W_ABSPATH . 'categories/clothes?s=woman" class="branch stage1">Одежда</a>';
				echo '<a href="' . W_ABSPATH . 'categories/shoes?s=woman" class="branch stage1">Обувь</a>';
			echo '</div>';
		echo '</div>';
	}
	*/
}